// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-11

package services

import (
	"context"
	"gitee.com/go-libs/db-xorm/db"
	"server/app/errs"
	"server/app/http/models"
	"server/app/kind"
)

func (o *ArcadeCalendarService) IncrExpense(ctx context.Context, cid int64, cost kind.Balance) (affects int64, err error) {
	var sess *db.Session
	if sess, err = o.Dao.Master(ctx); err != nil {
		err = errs.ErrDatabaseQuery
		return
	}
	if affects, err = sess.Incr("expenses", cost).Where("id=?", cid).Update(models.ArcadeCalendar{}); err != nil {
		err = errs.ErrDatabaseQuery
	}
	return
}

func (o *ArcadeCalendarService) IncrIncome(ctx context.Context, cid int64, cost kind.Balance) (affects int64, err error) {
	var sess *db.Session
	if sess, err = o.Dao.Master(ctx); err != nil {
		err = errs.ErrDatabaseQuery
		return
	}
	if affects, err = sess.Incr("incomes", cost).Where("id=?", cid).Update(models.ArcadeCalendar{}); err != nil {
		err = errs.ErrDatabaseQuery
	}
	return
}
